<!DOCTYPE html>

<!--
  Google HTML5 slide template

  Authors: Luke Mahé (code)
           Marcin Wichary (code and design)
           
           Dominic Mazzoni (browser compatibility)
           Charles Chen (ChromeVox support)

  URL: http://code.google.com/p/dp-svn-tutorial/
-->

<html>
  <head>
    <title>SVN - Advanced Topics</title>

    <meta charset='utf-8'>
    <script
      src='../slides.js'></script>
  </head>
  
  <style>
    /* Your individual styles here, or just use inline styles if that’s
       what you want. */
    
    
  </style>

  <body style='display: none'>

    <section class='slides layout-regular template-default'>
      
      <!-- Your slides (<article>s) go here. Delete or comment out the
           slides below. -->
        
        
      
      <article class='biglogo'>
      </article>

      <article>
        <h1>
          SVN Tutorial
          <br>
          Branches And Advanced Topics
        </h1>
        <p>
          Uli Heller
          <br>
          September 7, 2011
        </p>
      </article>
      
      <article>
        <h3>
          Agenda
        </h3>
        <ul>
          <li>Recap
          <li>Introduction Into Branches
          <li>Maintenance Branches
          <li>Merges
          <li>Feature Branches
          <li>Tags
          <li>Lessons Learned
        </ul>
      </article>

      <article>
        <h3>
          Recap
        </h3>
        <p>
         In the first part, we learned:
        </p>
        <ul>
          <li>Checkout, Update
          <li>Status
          <li>Commit
          <li>Conflict - short introduction
          <li>Log (version history)
          <li>Diff
        </ul>
        <p>
         In the second part, we focused on conflicts:
        </p>
        <ul>
          <li>Which types do exist?
          <li>How do you handle them?
        </ul>
      </article>

      <article>
        <h3>
          Repetition And Clarifications
        </h3>
        <p>
         In the first part, we learned:
        </p>
        <ul>
          <li>Execute <code>svn update</code> often!
             <br>Not doing it can create tree conflicts!
             <a href="../example-commands/forgotten-update.txt">
                  <object data="images/dp-gnome-terminal.svg" width="30" height="30" type="image/svg+xml">
                     <param name="src" value="images/dp-gnome-terminal.svg">
                     [link]
                     <embed src="images/dp-gnome-terminal.svg" width="30" height="30" type="image/svg+xml" />
                  </object>
             </a>
          <li>Execute <code>svn status</code> often!
              Especially before committing!
          <li>Commit as fast and as often as you can!
              <br>(The first committer doesn't get the
              conflict)
          <li>In case of a conflict, execute <code>svn update</code>,
              <code>svn status</code> and <code>svn log .</code> for help
          <li>Differentiate between conflict resolution and merging!
              <br>(Merging is better reserved for branches)
        </ul>
      </article>

       <article class="smaller">
        <h3>
          Branches - Introduction
        </h3>
        <p>
          <!--<img class='centered' src='images/branches_intro.png'>-->
          <object data="images/branches_intro.svg" type="image/svg+xml">
             <param name="src" value="images/branches_intro.svg">
             [link]
             <embed src="images/branches_intro.svg" type="image/svg+xml" />
          </object>
        </p>
        <ul>
          <li>You're preparing for release 1.0
          <li>You decide: rev1042 looks promising and will be
              used as basis for the release
          <li>Some testing and bug fixes are probably still required
          <li>Part of your team makes the code ready to ship
          <li>Others continue to work on trunk, these changes
              shall not go into the release
          <li>You have to create a branch for the shipment team
              leading to 1.0 (and beyond)
        </ul>
      </article>

      <article class="smaller">
        <h3>
          Branches - Copies Of Trunk
        </h3>
        <p>
          <!--<img class='centered' src='images/branches.png'>-->
          <object data="images/branches.svg" type="image/svg+xml">
             <param name="src" value="images/branches.svg">
             [link]
             <embed src="images/branches.svg" type="image/svg+xml" />
          </object>
        </p>
        <ul>
          <li>Branches are copies from "trunk" to "branches" (... most of
              the time)
          <li><code>svn cp ${url}/trunk ${url}/branches/1.0_maint</code>
              <br>or: <code>svn cp ^/trunk ^/branches/1.0_maint</code>
              <br>Note: This is fragile!
          <li><code>svn cp ^/trunk@10 ^/branches/2.0_maint</code>
          <li>Copies are cheap
          <li>Server-side copies are fast (you specify 2 urls)
          <li>Be careful with the names of the branches
        </ul>
        <p>
             <a href="../example-repo/sample2.repo.svn_13.zip">
                  <object data="images/Subversion_logo.svg" height="20" type="image/svg+xml">
                     <param name="src" value="images/Subversion_logo.svg">
                     [link]
                     <embed src="images/Subversion_logo.svg" height="20" type="image/svg+xml" />
                  </object>
             </a>
        </p>
      </article>

      <article>
        <h3>
          Maintenance Branches - Introduction
        </h3>
        <p>
          <!--<img class='centered' src='images/maintenance_branch.png'>-->
          <object data="images/maintenance_branch.svg" type="image/svg+xml">
             <param name="src" value="images/maintenance_branch.svg">
             [link]
             <embed src="images/maintenance_branch.svg" type="image/svg+xml" />
          </object>
        </p>
        <ul>
          <li>Maintenance branches are branches which you use to prepare
              and maintain releases of your product
          <li>Maintenance branches are typically copies of trunk
          <li>Maintenance branches live forever
          <li>Feature branches terminate on completion
        </ul>
      </article>

      <article class="smaller">
        <h3>
          Maintenance Branches - Merge Change From Trunk
        </h3>
        <p>
          <!--<img class='centered' src='images/merge_from_trunk.png'>-->
          <object data="images/merge_from_trunk.svg" type="image/svg+xml">
             <param name="src" value="images/merge_from_trunk.svg">
             [link]
             <embed src="images/merge_from_trunk.svg" type="image/svg+xml" />
          </object>
        </p>
        <p>
          Sometimes, you'll realize that a certain change has to
          be ported from trunk to a maintenance branch. How can you do this?
        </p>
        <ul class="build">
          <li>Make sure: You have a clean working copy of the branch
             <br><code>svn -q update; svn status</code> ... no output
          <li>Create a DIFF for the trunk and PATCH the branch accordingly
          <li><code>svn diff -c6 ^/trunk|patch -p0 --merge</code>
          <li>What happens, if you try to do this twice?
          <li>You get a conflict!
          <li>So: You have to keep track about your merges
        </ul>
         <p class="build">
             <a href="../example-commands/merge-from-trunk.txt">
                  <object data="images/dp-gnome-terminal.svg" width="30" height="30" type="image/svg+xml">
                     <param name="src" value="images/dp-gnome-terminal.svg">
                     [link]
                     <embed src="images/dp-gnome-terminal.svg" width="30" height="30" type="image/svg+xml" />
                  </object>
             </a>
         </p>
      </article>

      <article class="smaller">
        <h3>
          Maintenance Branches - Merge Change To Trunk
        </h3>
        <p>
          <!--<img class='centered' src='images/merge_from_branch.png'>-->
          <object data="images/merge_from_branch.svg" type="image/svg+xml">
             <param name="src" value="images/merge_from_branch.svg">
             [link]
             <embed src="images/merge_from_branch.svg" type="image/svg+xml" />
          </object>
        </p>
        <p>
          Sometimes, you'll realize that a certain change has to
          be ported from a maintenance branch to trunk. How can you do this?
        </p>
        <ul class="build">
          <li>Make sure: You have a clean working copy of the trunk
             <br><code>svn -q update; svn status</code> ... no output
          <li>Create a DIFF for the branch and PATCH the trunk accordingly
          <li><code>svn diff -c13 ^/branches/1.0_maint|patch -p0</code>
          <li>What happens, if you try to do this twice?
               -> You get a conflict!
          <li>What happens if you pick the change of the reverse merge?
               -> You get a conflict!
          <li>So: You have to keep track about your merges (both
              directions)
        </ul>
        <p class="build">
             <a href="../example-commands/merge-from-branch.txt">
                  <object data="images/dp-gnome-terminal.svg" width="30" height="30" type="image/svg+xml">
                     <param name="src" value="images/dp-gnome-terminal.svg">
                     [link]
                     <embed src="images/dp-gnome-terminal.svg" width="30" height="30" type="image/svg+xml" />
                  </object>
             </a>
        </p>
      </article>

      <article class="smaller">
        <h3>
          Maintenance Branches - Merge All To Trunk
        </h3>
        <p>
          <!--<img class='centered' src='images/merge_all_from_branch.png'>-->
          <object data="images/merge_all_from_branch.svg" type="image/svg+xml">
             <param name="src" value="images/merge_all_from_branch.svg">
             [link]
             <embed src="images/merge_all_from_branch.svg" type="image/svg+xml" />
          </object>
        </p>
        <p>
          Sometimes, you'll realize that all changes from a maintenance branch
          have to be ported to trunk.
        </p>
        <p>
          Motivation: You want to be sure that all bug fixes are available
          in trunk!
        </p>
        <p>
          You'll probably want to do this multiple times, for example every
          month!
        </p>
        <p>
          <code>svn diff -r3:13 ^branches/1.0_maint|patch -p0</code>
          <br><code>svn diff -r3:HEAD ^branches/1.0_maint|patch -p0</code>
        </p>
        <p class="build">
             <a href="../example-commands/merge-all-from-branch.txt">
                  <object data="images/dp-gnome-terminal.svg" width="30" height="30" type="image/svg+xml">
                     <param name="src" value="images/dp-gnome-terminal.svg">
                     [link]
                     <embed src="images/dp-gnome-terminal.svg" width="30" height="30" type="image/svg+xml" />
                  </object>
             </a>
        </p>
      </article>

      <article>
        <h3>
          Maintenance Branches - Merge All From Trunk
        </h3>
        <p>
          <!--<img class='centered' src='images/merge_all_from_trunk.png'>-->
          <object data="images/merge_all_from_trunk.svg" type="image/svg+xml">
             <param name="src" value="images/merge_all_from_trunk.svg">
             [link]
             <embed src="images/merge_all_from_trunk.svg" type="image/svg+xml" />
          </object>
        </p>
        <p class="build">
          Sometimes, you'll realize that all changes from trunk
          have to be ported to a maintenance branch.
        </p>
        <p class="build">
          <b>NO - This is not a typical use case!!</b>
        </p>
      </article>

      <article class="smaller">
        <h3>
          Maintenance Branches - Merge Tracking (1/2)
        </h3>
        <p>
          <!--<img class='centered' src='images/merge-tracking.png'>-->
          <object data="images/merge-tracking.svg" type="image/svg+xml">
             <param name="src" value="images/merge-tracking.svg">
             [link]
             <embed src="images/merge-tracking.svg" type="image/svg+xml" />
          </object>
        </p>
        <ul class="build">
         <li>Merge c6 from trunk into branch: <code>svn merge -c6 ^/trunk</code>
             (r14, see below!)
         <li>Merge c13 from branch into trunk: <code>svn merge -c13 ^/branches/1.0_maint</code>
         <li>Merge range from branch into trunk:
             <br><code>svn merge -r7:13 ^/branches/1.0_maint</code>
         <li>Merge all from branch into trunk: <code>svn merge ^/branches/1.0_maint</code>
             <br>... creates a conflict
         <li>Merge all from branch into trunk:
             <br><code>svn merge --record-only -c14 ^/branches/1.0_maint</code>
             <br><code>svn merge ^/branches/1.0_maint</code>
             <br>Best practice: Do the "--record-only" already when merging
                 to a maintenance branch!
        </ul>
        <p class="build">
             <a href="../example-commands/merge-tracking.txt">
                  <object data="images/dp-gnome-terminal.svg" width="30" height="30" type="image/svg+xml">
                     <param name="src" value="images/dp-gnome-terminal.svg">
                     [link]
                     <embed src="images/dp-gnome-terminal.svg" width="30" height="30" type="image/svg+xml" />
                  </object>
             </a>
             <a href="../example-repo/sample2.repo.svn_16.zip">
                  <object data="images/Subversion_logo.svg" height="20" type="image/svg+xml">
                     <param name="src" value="images/Subversion_logo.svg">
                     [link]
                     <embed src="images/Subversion_logo.svg" height="20" type="image/svg+xml" />
                  </object>
             </a>
        </p>
      </article>

      <article>
        <h3>
          Maintenance Branches - Merge Tracking (2/2)
        </h3>
        <ul class="build">
         <li>Merge tracking has to be supported by the svn
             client and by the svn server
          <span style="font-size:smaller; line-height:80%">
           <ul class="build">
            <li>You have to use version 1.5 or newer on both sides
            <li>Tricky for 3rd party clients - different version numbers
            <li>As of Summer 2011, version 1.7 will be released soon
           </ul>
          </span>
         <li>Merge tracking must be used for all merges!
          <span style="font-size:smaller; line-height:80%">
           <ul class="build">
            <li>Using it only for some merges leads to incomplete tracking
                information - worthless
            <li>Each merging developer has to use a compatible client
           </ul>
          </span>
         <li>Each change/fix must be added to the repo only once
          <span style="font-size:smaller; line-height:80%">
           <ul class="build">
            <li>If you want it in multiple branches, add it into one
                and merge from there
            <li>Adding it to multiple branches is similar to merging without
                merge tracking
           </ul>
          </span>
         <li>Technical background
          <span style="font-size:smaller; line-height:80%">
           <ul class="build">
            <li>svn:mergeinfo is used for merge tracking
            <li>It is a svn property
            <li>It stores numbers of all merged changes
           </ul>
          </span>
        </ul>
      </article>

      <article class="smaller">
        <h3>
          Maintenance Branches - Switch
        </h3>
        <p>
          <!--<img class='centered' src='images/branches_intro.png'>-->
          <object data="images/branches_intro.svg" type="image/svg+xml">
             <param name="src" value="images/branches_intro.svg">
             [link]
             <embed src="images/branches_intro.svg" type="image/svg+xml" />
          </object>
        </p>
        <p>
          Sometimes, you have to work in parallel on trunk
          and on a maintenance branch.
        </p>
        <ul class="build">
          <li>Keep two separate working copies (lots of  disk space)
          <li>Delete current working copy and
              do a fresh checkout (huge data transfer)
          <li>Switch current working copy
              (only the changes are transferred)
          <li>Before each switch: Make sure you have a clean working copy
             <br><code>svn -q update; svn status</code> ... no output
          <li><code>svn switch ^/branches/1.0_maint</code> ... now work on
             branch
          <li><code>svn switch ^/trunk</code> ... now work on trunk
        </ul>
        <p class="build">
             <a href="../example-commands/switch.txt">
                  <object data="images/dp-gnome-terminal.svg" width="30" height="30" type="image/svg+xml">
                     <param name="src" value="images/dp-gnome-terminal.svg">
                     [link]
                     <embed src="images/dp-gnome-terminal.svg" width="30" height="30" type="image/svg+xml" />
                  </object>
             </a>
        </p>
      </article>

      <article class="smaller">
        <h3>
          Feature Branches
        </h3>
        <p>
          <!--<img class='centered' src='images/feature_branch.png'>-->
          <object data="images/feature_branch.svg" type="image/svg+xml">
             <param name="src" value="images/feature_branch.svg">
             [link]
             <embed src="images/feature_branch.svg" type="image/svg+xml" />
          </object>
        </p>
        <ul>
          <li>Feature branches are used to develop new features
          <li>Should be kept "near" to base branch to
              simplify the final merge (see below)
             <br>(merge often from base to feature branch)
             <br><code>svn merge ^/trunk</code>
          <li>Feature branches terminate on completion
          <li>Termination means: Merge all changes into the base branch
              (reintegrate)
             <br><code>svn merge --reintegrate ^/branches/feature-getopt</code>
          <li>Feature branches typically deleted on completion
             <br><code>svn rm ^/branches/feature-getopt</code>
        </ul>
        <p class="build">
             <a href="../example-commands/feature-branch.txt">
                  <object data="images/dp-gnome-terminal.svg" width="30" height="30" type="image/svg+xml">
                     <param name="src" value="images/dp-gnome-terminal.svg">
                     [link]
                     <embed src="images/dp-gnome-terminal.svg" width="30" height="30" type="image/svg+xml" />
                  </object>
             </a>
             <a href="../example-repo/sample2.repo.svn_24.zip">
                  <object data="images/Subversion_logo.svg" height="20" type="image/svg+xml">
                     <param name="src" value="images/Subversion_logo.svg">
                     [link]
                     <embed src="images/Subversion_logo.svg" height="20" type="image/svg+xml" />
                  </object>
             </a>
        </p>
      </article>

      <article>
        <h3>
          Tags - Introduction
        </h3>
        <p>
         Sometimes, you have to mark special revisions
         in your svn repository
        </p>
          <p>
          <!--<img class='centered' src='images/versions.png'>-->
          <object data="images/versions.svg" type="image/svg+xml">
             <param name="src" value="images/versions.svg">
             [link]
             <embed src="images/versions.svg" type="image/svg+xml" />
          </object>
        </p>
        <ul>
          <li>Mark with a version number (1.0, 2.0, etc)
          <li>Mark with a build number (1, 2, 3, 4, etc)
          <li>Mark with a customer name
        </ul>
        <p>
         In svn, these marks are called <em>tags</em>
        </p>
      </article>

      <article class="smaller">
        <h3>
          Tags - How
        </h3>
        <p>
          <!--<img class='centered' src='images/tags.png'>-->
          <object data="images/tags.svg" type="image/svg+xml">
             <param name="src" value="images/tags.svg">
             [link]
             <embed src="images/tags.svg" type="image/svg+xml" />
          </object>
        </p>
        <ul>
          <li>Tags are created by copying a revision or working copy
              into the tags folder
          <li>Examples:
           <ul>
             <li><code>svn cp ^/trunk ^/tags/1.0</code>
             <li><code>svn cp -r3 ^/trunk ^/tags/1.0</code>
             <li><code>svn cp ^/trunk@3 ^/tags/1.0</code>
           </ul>
          <li>Copies of working copies can create complex mixed version tags
          <li>Copying working copies is slow
        </ul>
      </article>
      
      <article>
        <h3>
          Tags - From Branches
        </h3>
        <p>
          <!--<img class='centered' src='images/tags_and_branches.png'>-->
          <object data="images/tags_and_branches.svg" type="image/svg+xml">
             <param name="src" value="images/tags_and_branches.svg">
             [link]
             <embed src="images/tags_and_branches.svg" type="image/svg+xml" />
          </object>
        </p>
        <p>
          Tags can be created from branches as well!
        </p>
      </article>

      <article>
        <h3>
          Tags - Never Change
        </h3>
        <p>
          <!--<img class='centered' src='images/modify-tags.png'>-->
          <object data="images/modify-tags.svg" type="image/svg+xml">
             <param name="src" value="images/modify-tags.svg">
             [link]
             <embed src="images/modify-tags.svg" type="image/svg+xml" />
          </object>
        </p>
        <ul>
          <li>Folders underneath "tags" are folders like all others
          <li>In theory, you can do a checkout and modify them
          <li>Convention: Never do this! Tags are forever!
        </ul>
      </article>

      <article>
        <h3>
          Subversion - Lessons Learned
        </h3>
        <ul>
          <li>Maintenance Branches
          <li>Feature Branches
          <li>Merges
          <li>Tags
        </ul>
      </article>

      <article>
        <h1>
          Thank You!
        </h1>
      </article>
    </section>

  </body>
</html>
